//Created by Action Script Viewer - http://www.buraks.com/asv
package mortal.game.resource {
	import mortal.common.global.*;
	import com.gengine.resource.*;
	import flash.utils.*;
	import com.gengine.resource.info.*;
	import mortal.game.scene.map.*;
	import mortal.game.model.*;
	
	public class SceneConfig {
		
		private var _map:Dictionary;
		private var _mapArray:Array;
		private var _refreshMap:Array;
		private var _sceneEffect:Array;
		private var _npcMap:Dictionary;
		
		private static var _instance:SceneConfig;
		
		public function SceneConfig(){
			var _local1:int;
			this._map = new Dictionary();
			this._npcMap = new Dictionary();
			super();
			if (_instance != null){
				throw (new Error(" SceneConfig 单例 "));
			};
			this._mapArray = GameDefConfig.instance.getLoadMapConfig(1);
			var _local2:int;
			while (_local2 < this._mapArray.length) {
				_local1 = int(this._mapArray[_local2]);
				this.addMiniMapInfo(_local1);
				this._mapArray[_local2] = _local1; 
				_local2++;
			};
			this._refreshMap = GameDefConfig.instance.getLoadMapConfig(2);
			var _local3:int;
			while (_local3 < this._refreshMap.length) {
				this._refreshMap[_local3] = int(this._refreshMap[_local3]);
				_local3++;
			};
			this._sceneEffect = GameDefConfig.instance.getLoadMapConfig(3);
			var _local4:int;
			while (_local4 < this._sceneEffect.length) {
				this._sceneEffect[_local4] = int(this._sceneEffect[_local4]);
				_local4++;
			};
			this.init();
		}
		private function addMiniMapInfo(_arg1:int):void{
			var _local2:ImageInfo;
			var _local3:String;
			var _local4:String = ((PathConst.mapPath + _arg1) + "/");
			_local3 = (_arg1 + "_mini.jpg");
			_local2 = new ImageInfo({name:_local3, type:".JPG", time:"1", path:(_local4 + _local3)});
			ResourceManager.addResource(_local2);
		}
		public function get allMap():Dictionary{
			return (this._map);
		}
		public function init():void{
			var _local3:int;
			var _local1:uint = this._mapArray.length;
			var _local2:uint;
			while (_local2 < _local1) {
				_local3 = this._mapArray[_local2];
				this._map[_local3] = this.initSceneInfo(_local3);
				_local2++;
			};
		}
		public function getSceneInfo(_arg1:int):SceneInfo{
			return ((this._map[_arg1] as SceneInfo));
		}
		protected function initSceneInfo(_arg1:Object):SceneInfo{
			var _local3:Object;
			var _local2:SceneInfo = (this._map[_arg1] as SceneInfo);
			if (_local2 == null){
				_local2 = new SceneInfo();
				_local3 = ConfigManager.instance.getJSONByFileName((_arg1 + "_scene.json"));
				_local2.readObj(_local3);
				if (this._refreshMap.indexOf(_arg1) != -1){
					_local2.readBossRefreshPoint(ConfigManager.instance.getJSONByFileName((_arg1 + "_BossRefreshPoint.json")));
				};
				if (this._sceneEffect.indexOf(_arg1) != -1){
					_local2.readSceneEffect(ConfigManager.instance.getJSONByFileName((_arg1 + "_sceneEffect.json")));
				};
				_local2.readBossAreaInfo(_local3);
			};
			return (_local2);
		}
		public function getSceneInfoByNpcId(_arg1:int):SceneInfo{
			var _local2:SceneInfo;
			var _local3:int;
			var _local4:NPCInfo;
			for each (_local3 in this._mapArray) {
				_local2 = this.getSceneInfo(_local3);
				for each (_local4 in _local2.npcInfos) {
					if (((!((_local4.tnpc == null))) && ((_local4.tnpc.npcId == _arg1)))){
						return (_local2);
					};
				};
			};
			return (null);
		}
		
		public static function get instance():SceneConfig{
			if (_instance == null){
				_instance = new (SceneConfig);
			};
			return (_instance);
		}
		
	}
}//package mortal.game.resource 
